<?php
namespace inkstones\config;

class Config{
	
	private static $fields=array();
	
	public static function get($key=''){
		if(strpos($key,'.')){
			$key=explode('.',$key);
			return self::$fields[$key[0]][$key[1]];
		}
		else{
			return empty($key)?self::$fields:self::$fields[$key];
		}
	}
	
	public static function set($key,$value=''){
		if(is_array($key)){
			self::$fields=array(self::$fields,$key);
		}
		elseif(is_string($key)){
			if(strpos($key,'.')){
				$key=explode('.',$key);
				self::$fields[$key[0]][$key[1]]=$value;
			}
			else{
				self::$fields[$key]=$value;
			}
		}
		
	}
	
	public static function has($key=''){
		if(strpos($key,'.')){
			$key=explode($key,'.');
			if(isset(self::$fields[$key[0]][$key[1]])){
				return true;
			}
		}
		elseif(isset(self::$fields[$key])){
			return true;
		}
		return false;
	}
	
	public static function reset($key=''){
		if(self::has($key) && !empty($key)){
			self::$fields[$key]=array();
		}
		else{
			self::$fields=array();
		}
	}
	
	public static function load($file){
		if(is_file($file)){
			$extension=pathinfo($file,PATHINFO_EXTENSION);
			if(strtolower($extension)=='php'){
				self::set(include_once($file));
			}
		}
	}
	
	public function t(){
		echo '<h3>config</h3>';
	}
	
}















?>





















